package com.dqyt.app.controller;

import com.alibaba.fastjson.JSON;
import com.dqyt.app.service.AppWorkService;
import com.dqyt.khjc.bean.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 样品控制器
 */
@RestController
public class AppWorkController {

    /**
     * 样品操作类
     */
    @Autowired
    private AppWorkService mWorkService;




    /**
     * 分页查询任务
     *
     * @param request
     * @return
     */
    @RequestMapping("/sample/getWorkListPage")
    public ResultMsg getWorkListPage(HttpServletRequest request,
                                     @RequestParam(defaultValue = "1") Integer page,
                                     @RequestParam(defaultValue = "10") Integer size,
                                     long userId,String token,
                                     @RequestParam(name = "rwdbh", required = false, defaultValue = "")  String rwdbh,
                                     @RequestParam(defaultValue = "0")Integer wtfId,
                                     @RequestParam(defaultValue = "0")Integer mtype,
                                     @RequestParam(defaultValue = "0")Integer workTYpe) {
        ResultMsg resultMsg = mWorkService.getWorkListPage(request,page,size,userId,token,rwdbh,wtfId,mtype,workTYpe);
        return resultMsg;
    }

    /**
     * 分页查询任务
     *
     * @param request
     * @return
     */
    @RequestMapping("/sample/getWorkListPagex")
    public ResultMsg getWorkListPagex(HttpServletRequest request,
                                     @RequestParam(defaultValue = "1") Integer page,
                                     @RequestParam(defaultValue = "10") Integer size,
                                     long userId,String token,
                                     @RequestParam(name = "rwdbh", required = false, defaultValue = "")  String rwdbh,
                                     @RequestParam(defaultValue = "0")Integer wtfId,
                                     @RequestParam(defaultValue = "0")Integer mtype,
                                     @RequestParam(defaultValue = "0")Integer workTYpe) {
        ResultMsg resultMsg = mWorkService.getWorkListPagex(request,page,size,userId,token,rwdbh,wtfId,mtype,workTYpe);
        return resultMsg;
    }




    /**
     * 分页查询任务
     *
     * @param request
     * @return
     */
    @RequestMapping("/sample/getWorkListPage2")
    public ResultMsg getWorkListPage2(HttpServletRequest request,
                                     @RequestParam(defaultValue = "1") Integer page,
                                     @RequestParam(defaultValue = "10") Integer size,
                                     long userId,String token,
                                     @RequestParam(name = "rwdbh", required = false, defaultValue = "")  String rwdbh,
                                     @RequestParam(defaultValue = "0")Integer wtfId,
                                     @RequestParam(defaultValue = "0")Integer mtype,
                                     @RequestParam(defaultValue = "0")Integer workTYpe) {
        ResultMsg resultMsg = mWorkService.getWorkListPage(request,page,size,userId,token,rwdbh,wtfId,mtype,workTYpe);
        return resultMsg;
    }



    /**
     * 快速分配任务
     *
     * @param request
     * @return
     */
    @RequestMapping("/sample/setAssignTasks")
    public ResultMsg setAssignTasks(HttpServletRequest request,String token,long userId,int type, long jcrId,String startNumber,String endNumber) {
        ResultMsg resultMsg = mWorkService.setAssignTasks(request,token,userId,type,jcrId,startNumber,endNumber);
        return resultMsg;
    }


    /**
     * 分配任务
     * @param request
     * @param token
     * @param userId
     * @param bsbhArrar
     * @param jcrUserId
     * @param jcrStr
     * @return
     */
    @RequestMapping("/sample/assignJobs")
    public  ResultMsg assignJobs(HttpServletRequest request,String token,long userId,String [] bsbhArrar,String jcrUserId,String jcrStr){
        ResultMsg resultMsg = mWorkService.assignJobs(request,token,userId,bsbhArrar,jcrUserId,jcrStr);
        return resultMsg;
    }




    /**
     * 分页查询任务
     *
     * @param request
     * @return
     */
    @RequestMapping("/sample/getWorkListPage5")
    public ResultMsg getWorkListPage(HttpServletRequest request,
                                     String token,long userId,
                                     @RequestParam(defaultValue = "1") Integer page,
                                     @RequestParam(defaultValue = "10") Integer size,
                                     @RequestParam(name = "rwdbh", required = false, defaultValue = "-1")  String rwdbh,
                                     @RequestParam(defaultValue = "-1") Integer wtfId,
                                     @RequestParam(defaultValue = "0")Integer mtype,
                                     @RequestParam(defaultValue = "0")Integer workTYpe,
                                     @RequestParam(defaultValue = "0")Integer workTYpeCh,
                                     @RequestParam(defaultValue = "0")Integer workTYpeCh2,
                                     @RequestParam(defaultValue = "0")Long jyyId
    ) {
        ResultMsg resultMsg = mWorkService.getWorkListPage5(request,token,userId,page,size,rwdbh,wtfId,mtype,workTYpe,workTYpeCh,workTYpeCh2,jyyId);
        return resultMsg;
    }



    /**
     * 设置任务状态 已打印
     * @param request
     * @param bsbhArrar  标识编号的数组
     * @return
     */
    @RequestMapping("/sample/setworkTYpeYdy")
    public  ResultMsg setworkTYpeYdy(HttpServletRequest request,String token,long userId,String [] bsbhArrar,int workTYpe){
        ResultMsg resultMsg = mWorkService.setworkTYpeYdy(request,token,userId,bsbhArrar,workTYpe);
        return resultMsg;
    }



    /**
     * 设置任务状态 已完成
     * @param request
     * @param bsbhArrar  标识编号的数组
     * @return
     */
    @RequestMapping("/sample/setworkTYpeYwc")
    public  ResultMsg setworkTYpeYwc(HttpServletRequest request,String token,long userId,String [] bsbhArrar){
        ResultMsg resultMsg = mWorkService.setworkTYpeYwc(request,token,userId,bsbhArrar);
        return resultMsg;
    }



    /**
     * 设置任务状态 已装箱
     * @param request
     * @param bsbhArrar  标识编号的数组
     * @return
     */
    @RequestMapping("/sample/setworkTYpeYzx")
    public  ResultMsg setworkTYpeYzx(HttpServletRequest request,String token,long userId,String [] bsbhArrar){
        ResultMsg resultMsg = mWorkService.setworkTYpeYzx(request,token,userId,bsbhArrar);
        return resultMsg;
    }



    /**
     * 设置任务状态 已发放
     * @param request
     * @param bsbhArrar  标识编号的数组
     * @return
     */
    @RequestMapping("/sample/setworkTYpeYff")
    public  ResultMsg setworkTYpeYff(HttpServletRequest request,String token,long userId,String [] bsbhArrar){
        ResultMsg resultMsg = mWorkService.setworkTYpeYff(request,token,userId,bsbhArrar);
        return resultMsg;
    }

}
